package org.jwos.platform.domain;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;

public class Plugin {
	
	public static final int TYPE_SYSTEM = 1;
	
	public static final int TYPE_PROGRAM = 2;
	
	public static final int TYPE_SETTING = 3;
	
	private int type = TYPE_PROGRAM;
	
	private String id;
	
	private String name;
	
	private String path;
	
	private int order;
	
	private List<PluginResource> resources = new ArrayList();
	
	private Map<Locale,PluginResource> localeResources = new HashMap();
	
	public Plugin() {
	}
	
	public void addResource(PluginResource resource) {
		this.resources.add(resource);
	}
	
	public void setLocaleResource(Locale locale,PluginResource resource) {
		this.localeResources.put(locale, resource);
	}
	
	public PluginResource getLocaleResource(Locale locale) {
		return this.localeResources.get(locale);
	}
	
	public PluginResource getLocaleResource(String locale) {
		Locale key = null;
		if(locale.equals("ja")) {
			key = Locale.JAPANESE;
		} else if(locale.equals("zh_CN")) {
			key = Locale.SIMPLIFIED_CHINESE;
		} else {
			key = Locale.ENGLISH;
		}
		return this.localeResources.get(key);
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	public int getOrder() {
		return order;
	}

	public void setOrder(int order) {
		this.order = order;
	}

	public List<PluginResource> getResources() {
		return resources;
	}

	public void setResources(List<PluginResource> resources) {
		this.resources = resources;
	}

	public Map<Locale, PluginResource> getLocaleResources() {
		return localeResources;
	}

	public void setLocaleResources(Map<Locale, PluginResource> localeResources) {
		this.localeResources = localeResources;
	}	
}
